//package com.woniu.config;
//
//
//
//import org.redisson.api.RBloomFilter;
//import org.redisson.api.RedissonClient;
//import org.springframework.boot.ApplicationArguments;
//import org.springframework.boot.ApplicationRunner;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//import javax.annotation.Resource;
//import java.awt.print.Book;
//import java.util.List;
//
//@Configuration
//public class MyBloomFilter implements ApplicationRunner {
//    //ApplicationRunner 这个接口在spring boot已启动的时候 会重写run方法
//    @Resource
//    private RedissonClient redissonClient;
//    @Bean
//    public RBloomFilter rBloomFilter(){
//
//        RBloomFilter<Integer> bookFilter = redissonClient.getBloomFilter("bookIdList");
//        System.out.printf(String.valueOf(bookFilter));
//        bookFilter.tryInit(1000,0.0001);
//        return bookFilter;
//    }
//
//    @Resource
//    private BookMapper bookMapper;
//    @Override
//    public void run(ApplicationArguments args) throws Exception {
//        RBloomFilter rBloomFilter = rBloomFilter();
//        if (rBloomFilter.count() == 0) {
//            List<Book> bookList = bookMapper.findOnline();
//            for (Book book : bookList) {
//                rBloomFilter.add(book.getId());
//            }
//            System.out.println("布隆过滤器重新加载");
//        }else {
//            System.out.println("布隆过滤器已存在");
//            System.out.println(rBloomFilter);
//        }
//
//    }
//}
